<?php
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of getlanguages
 *
 * @author srkrishnan
 */

/**

 * @property CI_Loader $load

 * @property CI_Form_validation $form_validation

 * @property CI_Input $input

 * @property CI_Email $email

 * @property CI_DB_active_record $db

 * @property CI_DB_forge $dbforge
 * 
 * @property problem $problem 

 */
class Getlanguages extends CI_Controller {

    private $userid = "anantha89", $password = "myideone";

    function Getlanguages() {
        parent::__construct();
        $this->load->helper('url');
    }

    function index() {
        $jsonresult = array();
        try {
            //create new SoapClient
            $client = new SoapClient("http://ideone.com/api/1/service.wsdl");

            $languages = $client->getLanguages($this->userid, $this->password);

            if ($languages['error'] != 'OK') {
                //error
            }

            $langs = $languages['languages'];
            $languageoption = "<select id=language class=language>";
            foreach ($langs as $langid => $langname) {
                $a = $langid;
                $b = $langname;
                $languageoption = $languageoption . "<option value=" . $langid . " >" . $langname . "</option>";
            }
            $languageoption = $languageoption . "</select>";

            $languageoption=$languageoption."<script src=". base_url() ."js/langoption.js></script>";
            
            
            
        } catch (Exception $e) {
            $jsonresult = array(
                'error' => $e
            );
        }
        
        echo $languageoption;
    }

}

?>
